<template>
  <el-card shadow="never">
    <div class="addBtnWrap">
      <el-tooltip class="item" effect="dark" content="新增" placement="top">
        <el-button icon="el-icon-plus" @click="handleEdit(false, {})" type="primary" />
      </el-tooltip>
    </div>
    <el-row style="margin-top: 10px;" :gutter="24">
      <el-col :md="4">
        <per-list ref="perList" @setFields="handleSetFields" />
      </el-col>
      <el-col :md="20">
        <i class="fs16 mt3 mr10 fl el-icon-warning-outline"></i>
        <h4 class="fl mb20">权限修改之后，需退出重新登录才能看到修改之后的效果</h4>
        <per-table ref="perTable" @edit="handleEdit" />
      </el-col>
    </el-row>
    <per-modal ref="perModal" @refresh="handleRefresh" />
  </el-card>
</template>

<script>
import PerList from './perList.vue'
import PerTable from './perTable.vue'
import PerModal from './perModal.vue'

export default {
  name: 'PermissionIndex',
  components: {
    PerList,
    PerTable,
    PerModal
  },
  data() {
    return {
      permissionId: ''
    }
  },
  methods: {
    handleEdit(bool, record) {
      this.$refs.perModal.edit(bool, record)
    },
    handleSetFields(id) {
      this.permissionId = id
      this.$refs.perTable.getId(id)
    },
    handleRefresh() {
      this.$refs.perTable.handleGetList({ permissionId: this.permissionId })
    }
  }
}
</script>

<style lang="less" scoped>
.addBtnWrap {
  text-align: right;
  margin-bottom: 10px;
}
.mt3 {
  margin-top: 3px;
}
</style>
